package org.yoki.edu.common.protocol.radius.attribute.attr.check;


import lombok.Getter;
import org.yoki.edu.common.protocol.radius.attribute.attr.type.IntegerTypeAttr;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2018/1/15$ 14:54$
 */
public class FramedRoutingAttr extends IntegerTypeAttr {

    public static final int ATTR_TYPE = 10;

    @Override
    public int getAttrType() {
        return ATTR_TYPE;
    }

    public FramedRoutingTypeEnum getFramedProtocolType() {
        return FramedRoutingTypeEnum.getByValue(this.value);
    }

    enum FramedRoutingTypeEnum {

        None(0, "None"),
        SendRoutingPackets(1, "Send routing packets"),
        ListenForRoutingPackets(2, "Listen for routing packets"),
        SendAndListen(1, "Send and Listen");

        @Getter
        private int value;
        @Getter
        private String name;

        FramedRoutingTypeEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public static FramedRoutingTypeEnum getByValue(Integer value) {
            if (null == value) {
                throw new IllegalArgumentException();
            }
            FramedRoutingTypeEnum[] enums = FramedRoutingTypeEnum.values();
            for (FramedRoutingTypeEnum e : enums) {
                if (e.getValue() == value.intValue()) {
                    return e;
                }
            }
            return null;
        }

    }

}


